//
//  KYAdvertRestrictionModel.m
//  KYKJPackDemo
//
//  Created by 罗新 on 2017/11/8.
//  Copyright © 2017年 ???. All rights reserved.
//

#import "KYAdvertRestrictionModel.h"

@implementation KYAdvertRestrictionModel
+ (instancetype)refreshDataWithDict:(NSDictionary *)dict{
    KYAdvertRestrictionModel *model = [[KYAdvertRestrictionModel alloc] init];
    model.urlstr = dict[@"value"];
    return model;
}
- (void)encodeWithCoder:(NSCoder*)aCoder {
    unsigned int count = 0;
    Ivar* ivars = class_copyIvarList([self class], &count);
    for (int i = 0; i < count; i++) {
        Ivar ivar = ivars[i];
        const char* name = ivar_getName(ivar);
        NSString* key = [NSString stringWithUTF8String:name];
        [aCoder encodeObject:[self valueForKey:key] forKey :key];
    }
    free(ivars);
}
- (id)initWithCoder:(NSCoder*)aDecoder {
    if (self == [super init]) {
        unsigned int count = 0;
        Ivar* ivars = class_copyIvarList([self class], &count);
        for (int i = 0; i < count; i++) {
            Ivar ivar = ivars[i];
            const char* name = ivar_getName(ivar);
            NSString* key = [NSString stringWithUTF8String:name];
            id value =  [aDecoder decodeObjectForKey:key];
            [self setValue:value forKey:key];
        }
        free(ivars);
    }
    return self;
}

@end
